<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no" />
		<title>首页</title>
		<link rel="stylesheet" type="text/css" href="../c/aui.css" />
		<link rel="stylesheet" type="text/css" href="../c/suxiangw.css" />
		<link rel="stylesheet" type="text/css" href="../c/animate.css" />
		<style>
			body{
				background: #161823;
			}
			#sx-footer{
				border-top:0.05rem solid #232323;
			}
		</style>
	</head>
	<body>
		<header class="aui-bar aui-bar-nav" id="sx-header">
			<div class="aui-title">
				消息
			</div>
			<a class="aui-pull-right aui-btn" tapmode onclick=""></a>
		</header>
		<footer class="aui-bar aui-bar-tab" id="sx-footer">
			<div class="aui-bar-tab-item" tapmode onclick="_index_win('index')">
				<div class="aui-bar-tab-label">
					首页
				</div>
			</div>
			<div class="aui-bar-tab-item" tapmode onclick="_index_win('tongcheng')">
				<div class="aui-bar-tab-label">
					热点
				</div>
			</div>
			<div class="aui-bar-tab-item" tapmode onclick="_index_win('fabu')">
				<img style="width: 2.2rem;" src="../i/add.png" />
			</div>
			<div class="aui-bar-tab-item aui-active" id="xiaoxi" tapmode onclick="_shuaxin('xiaoxi')">
				<div class="aui-bar-tab-label">
					消息
				</div>
				<em></em>
				<div class="aui-badge aui-hide"></div>
			</div>
			<div class="aui-bar-tab-item" tapmode onclick="_index_win('member')">
				<div class="aui-bar-tab-label">
					我的
				</div>
			</div>
		</footer>
	</body>
	<script type="text/javascript" src="../j/api.js"></script>
	<script type="text/javascript">
		var no = false;
		apiready = function() {
			api.execScript({
			    name: 'root',
			    script: 'getTotalUnreadCount();'
			});
			_frame('xiaoxi');
			// 接收消息
			api.addEventListener({
			    name: 'xiaoxi'
			}, function(ret, err) {
				var _this = $('.aui-badge');
				if(ret.value.money){
					_this.removeClass('aui-hide');
					if(no){
						_this.addClass('animated swing');
						_this.one('webkitAnimationEnd', function(ret){
							_this.removeClass('animated swing');
						});
					}
					_this.text(ret.value.money);
				}else{
					_this.addClass('aui-hide');
				}
				no = true;
			});
		}
		// 刷新列表以及图标
		function list(){
			api.execScript({
			    frameName: 'xiaoxi',
			    script: 'list()'
			});
		}
		function clearConversations(){
			api.confirm({
			    title: '选择确定操作',
			    msg: '您确定要清空所有会话及会话消息？',
			    buttons: ['取消', '确定']
			}, function(ret, err) {
			    var index = ret.buttonIndex;
					if(index == 2){
						api.execScript({
						    frameName: 'xiaoxi',
						    script: 'clearConversations()'
						});
					}
			});
		}
	</script>
</html>
